
/*
 * Copyright 2002-2018 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/*
 *版权所有2002-2018原作者。
 *
 *根据Apache许可证2.0版（“许可证”）获得许可；
 *除非符合许可证，否则不得使用此文件。
 *您可以在以下地址获取许可证副本：
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 *除非适用法律要求或书面同意，软件
 *根据许可证分发的内容是按“原样”分发的，
 *无任何明示或暗示的保证或条件。
 *有关管理权限和
 *许可证下的限制。
 */

package org.springframework.beans.factory;

/**
 * Extension of the {@link FactoryBean} interface. Implementations may
 * indicate whether they always return independent instances, for the
 * case where their {@link #isSingleton()} implementation returning
 * {@code false} does not clearly indicate independent instances.
 *
 * <p>Plain {@link FactoryBean} implementations which do not implement
 * this extended interface are simply assumed to always return independent
 * instances if their {@link #isSingleton()} implementation returns
 * {@code false}; the exposed object is only accessed on demand.
 *
 * <p><b>NOTE:</b> This interface is a special purpose interface, mainly for
 * internal use within the framework and within collaborating frameworks.
 * In general, application-provided FactoryBeans should simply implement
 * the plain {@link FactoryBean} interface. New methods might be added
 * to this extended interface even in point releases.
 *
 * @author Juergen Hoeller
 * @since 2.0.3
 * @param <T> the bean type
 * @see #isPrototype()
 * @see #isSingleton()
 */
/**
 *｛@link FactoryBean｝接口的扩展。实施可能
 *指示它们是否始终返回独立实例
 *返回｛@link#isSingleton（）｝实现的情况
 *｛@code false｝未明确表示独立实例。
 *
 *＜p＞没有实现的普通｛@link FactoryBean｝实现
 *这个扩展接口被简单地假设为总是返回独立的
 *如果其｛@link#isSingleton（）｝实现返回
 *｛@code false｝；仅在需要时访问暴露的对象。
 *
 *<p><b>注意：</b>此接口是一个专用接口，主要用于
 *框架内和合作框架内的内部使用。
 *通常，应用程序提供的FactoryBean应该简单地实现
 *简单的｛@link FactoryBean｝接口。可能会添加新方法
 *即使在点版本中，也可以使用此扩展接口。
 *
 *@作者Juergen Hoeller
 *@自2.0.3起
 *@param＜T＞bean类型
 *@参见#isPrototype（）
 *@参见#isSingleton（）
 */
public interface SmartFactoryBean<T> extends FactoryBean<T> {

	/**
	 * Is the object managed by this factory a prototype? That is,
	 * will {@link #getObject()} always return an independent instance?
	 * <p>The prototype status of the FactoryBean itself will generally
	 * be provided by the owning {@link BeanFactory}; usually, it has to be
	 * defined as singleton there.
	 * <p>This method is supposed to strictly check for independent instances;
	 * it should not return {@code true} for scoped objects or other
	 * kinds of non-singleton, non-independent objects. For this reason,
	 * this is not simply the inverted form of {@link #isSingleton()}.
	 * <p>The default implementation returns {@code false}.
	 * @return whether the exposed object is a prototype
	 * @see #getObject()
	 * @see #isSingleton()
	 */
	/**
	 *这个工厂管理的对象是原型吗？即，
	 *｛@link#getObject（）｝是否始终返回独立实例？
	 *＜p＞FactoryBean本身的原型状态通常
	 *由拥有的｛@link BeanFactory｝提供；通常，它必须是
	 *在那里定义为单例。
	 *＜p＞该方法应严格检查独立实例；
	 *它不应为作用域对象或其他对象返回｛@code true｝
	 *各种非单例、非独立对象。由于这个原因，
	 *这不仅仅是{@link#isSingleton（）}的反转形式。
	 *＜p＞默认实现返回｛@code false｝。
	 *@return暴露的对象是否为原型
	 *@参见#getObject（）
	 *@参见#isSingleton（）
	 */
	default boolean isPrototype() {
		return false;
	}

	/**
	 * Does this FactoryBean expect eager initialization, that is,
	 * eagerly initialize itself as well as expect eager initialization
	 * of its singleton object (if any)?
	 * <p>A standard FactoryBean is not expected to initialize eagerly:
	 * Its {@link #getObject()} will only be called for actual access, even
	 * in case of a singleton object. Returning {@code true} from this
	 * method suggests that {@link #getObject()} should be called eagerly,
	 * also applying post-processors eagerly. This may make sense in case
	 * of a {@link #isSingleton() singleton} object, in particular if
	 * post-processors expect to be applied on startup.
	 * <p>The default implementation returns {@code false}.
	 * @return whether eager initialization applies
	 * @see org.springframework.beans.factory.config.ConfigurableListableBeanFactory#preInstantiateSingletons()
	 */
	/**
	 *这个FactoryBean是否期望立即初始化，
	 *急切地初始化自己以及期待急切的初始化
	 *它的单例对象（如果有的话）？
	 *＜p＞标准FactoryBean不应急于初始化：
	 *它的｛@link#getObject（）｝将仅用于实际访问，甚至
	 *在单例对象的情况下。从中返回｛@code true｝
	 *方法建议立即调用｛@link#getObject（）｝，
	 *也急切地应用后处理器。这可能有道理
	 *｛@link#isSingleton（）singleton｝对象，特别是如果
	 *后处理器预计在启动时应用。
	 *＜p＞默认实现返回｛@code false｝。
	 *@return是否应用紧急初始化
	 *@see org.springframework.beans.factory.config.ConfigableListableBeanFactory#preInstantiateSingletons（）
	 */
	default boolean isEagerInit() {
		return false;
	}

}
